You are here: Symbol Reference > Dew Namespace > Dew.Math Namespace > Classes > TMtxExpression Class > TMtxExpression Methods > TMtxExpression.DefineDouble Method
Dew Math for .NET
ContentsIndexHome
PreviousUpNext
TMtxExpression.DefineDouble Method

Defines new double variable.

Syntax
C#
Visual Basic
public TDoubleValue DefineDouble([In] string AVarName);

If variable with name AVarName already was definded, it will be redefined and all expressions which contain the symbol AVarName will be recompiled before the next evaluation.

Use parser to evaluate the "Sqrt(X*X + Y*Y)" formula where x=3 and y=4.

using Dew.Math; using Dew.Math.Units; namespace Dew.Examples() { void Example() { // 1. Define variables TDoubleValue x = MyParser.DefineDouble("x"); TDoubleValue y = MyParser.DefineDouble("y"); // 2. Set values x.DoubleValue = 3.0; y.DoubleValue = 4.0; // 3. Add formula and evaluate, MyParser.AddExpr("Sqrt(x*x+y*y)"); double res = MyParser.EvaluateDouble(); // res = 5 } }
Copyright (c) 1999-2024 by Dew Research. All rights reserved.
What do you think about this topic? Send feedback!